<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="org.wso2.carbon.registry.common.utils.RegistryUtil" %>
<%@ page import="org.wso2.carbon.registry.custom.dia.ui.utils.GetDocumentUtil" %>
<%@ page import="org.wso2.carbon.registry.common.ui.UIException" %>
<%@ page import="org.wso2.carbon.registry.custom.dia.ui.beans.EndpointBean" %>
<%@ page import="org.wso2.carbon.registry.custom.dia.ui.clients.TopicServiceClient" %>
<%@ page import="org.wso2.carbon.registry.custom.dia.ui.beans.xsd.TagBean" %>
<%@ page import="org.wso2.carbon.registry.custom.dia.ui.beans.xsd.AssociationBean" %>

<%
    String parentPath = request.getParameter("parentPath");
    String products[] = {"-Select One-","ESB","GReg","IS","BAM","GS","BPS","MS","DSS","WSAS","WSF"};
/*
     String ESB[] = {"2.1.3","2.1.2","2.1.1","2.1.0","2.0.2","2.0.1","2.0"};
     String GReg[] = {"3.0.3","3.0.2","3.0.1","3.0.0","2.0"};
     String IS[] = {"2.0.3","2.0.2","2.0.1","2.0.0"};
     String BAM[] ={"1.0.1"};
     String GS[] = {"1.0.1"};
     String BPS[] = {"1.1.1","1.1.0","1.0.1","1.0"};
     String MS[] = {"2.0.2","2.0.1","2.0.0","1.5.2"};
     String DSS[] = {"2.2.1","2.2.0","2.0.0","1.0.1"};
     String WSAS[] = {"3.1.3","3.1.2","3.1.1","3.0.1","3.0"};
*/
     String cP[] = {"-Select One-","2.0.3","2.0.2","2.0.1","2.0.0"};
     String jdkP[] = {"-Select One-","1.6","1.5"};

    String cPath = request.getParameter("path");
    EndpointBean bean;
    String tagString="";
    try {
        GetDocumentUtil getDocumentUtil = new GetDocumentUtil(config, session);
        bean = getDocumentUtil.getEndpointBean(cPath, config, session);

        TopicServiceClient client = new TopicServiceClient(config, session);
        TagBean[] tagBeans = client.getTags(cPath);

        if(tagBeans != null){
            for(TagBean tagBean:tagBeans){
                tagString += tagBean.getTagName() + ", ";
            }
            tagString = tagString.substring(0,tagString.length()-1);
        }
    } catch (UIException e) {
        %>Error occured while retrieving endpoint details<%
        return;
    } 
%>

<br/>


<br/>
<input type="hidden" id="sPath" name="sPath" value=""/>
<!--
<form id="diaAddForm" action="../registry/custom/dia/dia_add_handler_ajaxprocessor.jsp" onsubmit="Post.Send(this); showHideCommon('otherData'); return false;" method="post">
-->
<form id="diaEditForm" action="dia_edit_handler_ajaxprocesssjor.jsp" method="post">
    <input type="hidden" name="path" value="<%=cPath%>"/>
    <input type="hidden" name="numOfAsso" id="numOfAsso" value="0"/>
    <table style="width:100%"  cellpadding="0" cellspacing="0" border="0" class="styledLeft">
            <thead>
                    <tr>
                            <th colspan="2">
    <strong>Edit Documentation</strong>
    </th>
        </tr>
            </thead>
            <tbody>
        <tr>
            <td class="leftCol-med">Title <span class="required">*</span></td>
            <td><input type="text" id="diaTitle" name="diaTitle" value="<%=bean.getTitle()%>"/></td>
        </tr>
        <tr>
            <td>Summary</td>
            <td><textarea name="diaSummary" rows="4" cols="20"><%=bean.getSummary()%></textarea></td>
        </tr>
        <tr>
            <td>External Link <span class="required">*</span></td>
            <td><input type="text" name="diaLink" value="<%=bean.getExternalLink()%>"/></td>
        </tr> 

<tr>
        <td>Relevant Product</td>
                <td>
                <div id="pID" >
                <table cellpadding="0" cellspacing="0" border="0" class="styledLeft">

                    <tbody>
                        <tr>
                        <td>Product</td>
                        <td>
                        <select id="product" name="product">
                        <%
                        for(int i=0; i< products.length; i++){
                            String name1 = products[i];
                            %>
                            <option value="<%= name1%>"><%= name1%></option>
                            <%
                        }
                        %>
                        </select>
                        </td>
                        </tr>
                       <tr>
                        <td>Product Release</td>
                        <td><input type="text" name="productRelease" id="productRelease" value="<%=bean.getProductRelease()%>"/></td>
                        </tr>

                    </tbody>
                </table>
                </div>
                </td>
    </tr>
    <tr>
        <td>Environment</td>

                <td>
                <div id="eID">
                <table cellpadding="0" cellspacing="0" border="0" class="styledLeft">
                    <tbody>
                        <tr>
                        <td>Carbon Platform</td>
                        <td>
                        <select id="carbonPlatform" name="carbonPlatform">
                        <%
                        for(int i=0; i< cP.length; i++) {
                            String name1 = cP[i];
                            %>
                            <option value="<%= name1%>"><%= name1%></option>
                            <%
                        }
                        %>
                        </select>
                        </td>
                        </tr>
                        <tr>
                        <td>JDK Platform</td>
                        <td>
                        <select id="jdkPlatform" name="jdkPlatform">
                        <%
                        for(int i=0; i< jdkP.length; i++) {
                            String name1 = jdkP[i];
                            %>
                            <option value="<%= name1%>"><%= name1%></option>
                            <%
                        }
                        %>
                        </select>
                        </td>
                        </tr>

                    </tbody>
                </table>
                </div>
                </td>
    </tr>
    <tr>
        <td class="leftCol-med">Related Documentations</td>
        <td>
        <div id="diaAddAsso">
            <table cellpadding="0" cellspacing="0" border="0" class="styledLeft">

                <tr>
                <td>Path <span class="required">*</span></td>
                <td>
                    <input type="text" name="aPath0" id="aPath0" value="http://a" />
                    <input type="button" class="button" value=".." title="Resource Tree" onclick="showResourceTree('aPath0');">
                </td>
                </tr>
                </table>
            <HR>
        </div>

    <div class="icon-link-ouside registryWriteOperation" class="box1-mid" >
        <a class="icon-link registryWriteOperation" style="background-image:url(../admin/images/add.gif);" onclick="addAssoTable();">
            Add Another Related Documentation
        </a>
    </div>
    <div>
</div>
</td>
</tr>

    <tr>
           <td>Tags</td>
          <!--  <td><i nput type="te xt" name="diaTags" id="diaTags"/></td> -->
      <td>
          <div style="height: auto;" id="diaAddTags" class="info-area"> <!-- class="box1-mid">-->

            <div id="diaTagAddDiv" class="icon-link-ouside registryWriteOperation" >
                <a onclick="javascript:showHideCommon('diaTagAddTable');if($('diaTagAddTable').style.display!='none')$('diaTags').focus();" style="background-image: url(../admin/images/add.gif);" class="icon-link registryWriteOperation">
                    Add Tags
                </a>
            </div>
            <div  id="diaTagAddTable" class="registryWriteOperation" style="margin-top: 10px; ">
                <input type="text" name="diaTags" id="diaTags" value="<%=tagString%>">
                <div style="font-style: italic; margin-top: 5px;">
                    <img alt=" " style="margin-right: 5px;" src="../info/images/help-small.jpg">
                    Use commas ("one, two") to add multiple tags.
                </div>
            </div>
      </div>
      </td>
        </tr> 
        <tr>
            <%--<td><input type="button" value="Save" onclick="submitCustomAddUIForm('diaAddForm', '../registry/custom/topics/dia_add_handler_ajaxprocessor.jsp')"/></td>--%>
            <td colspan="2"><input type="button" value="Save" /></td>
        </tr>
    </tbody>
    </table>
</form>
        
 